package com.hms.dao.impl;

import org.springframework.stereotype.Component;

import com.hms.common.Common;
import com.hms.dao.IIndustryDao;
import com.hms.entity.TdIndustry;

/**
 * 标题、简要说明. <br>
 * 类详细说明.
 * <p>
 * Copyright: Copyright (c) 2013-4-13 上午11:37:33
 * <p>
 * Company: 北京宽连十方数字技术有限公司
 * <p>
 * 
 * @author wangpz@c-platform.com
 * @version 1.0.0
 */
@Component
public class IndustryDao extends BaseDao<TdIndustry, String> implements IIndustryDao {

	@Override
	public String save(TdIndustry entity) {
		String id = super.save(entity);
		TdIndustry parent = entity.getParentIndustry();
		if (null != parent) {
			String path = parent.getPath() + Common.PATH_SEPARATOR + entity.getPath();
			entity.setPath(path);
			entity.setParentIndustry(parent);
		} else {
			entity.setPath(id);
			entity.setParentIndustry(entity);
		}
		super.update(entity);
		return id;
	}
}
